namespace LightBox
{
    using System;
    using System.ComponentModel;
    using System.Globalization;
    using System.Security.Permissions;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;

    /// <summary>
    /// 
    /// </summary>
    [ToolboxData("<{0}:hyperlink runat='server'></{0}:hyperlink>")]
    [AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
    [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
    public class HyperLink : System.Web.UI.WebControls.HyperLink
    {
        /// <summary>
        /// 
        /// </summary>
        public HyperLink() { }

        /// <summary>
        /// 
        /// </summary>
        [Bindable(true), Localizable(true)]
        [Category("Appearance"), DefaultValue("")]
        public virtual string Group
        {
            get { return ViewState["groupName"] as string; }
            set { ViewState["groupName"] = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="writer"></param>
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            string attributeValue = (string.IsNullOrEmpty(Group)) ? "lightbox" : "lightbox[" + Group + "]";

            writer.AddAttribute(HtmlTextWriterAttribute.Rel, attributeValue);
            base.AddAttributesToRender(writer);
        }
    }
}